<%@ page import="com.deepai.dprsmgr.utils.ErrCode" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@include file="../base_path.jsp" %>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-cache"/>
    <meta http-equiv="Expires" content="0">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="description" content="">

    <link rel="stylesheet" type="text/css" href="<%=basePath%>/lib/bootstrap/3.3.7/css/bootstrap.min.css"/>
    <link rel="stylesheet" type="text/css" media="screen" href="<%=basePath%>/lib/lobibox/css/lobibox.min.css"/>
    <link rel="stylesheet" type="text/css" media="screen" href="<%=basePath%>/css/mycss.css"/>
    <title>外呼环境配置</title>
</head>
<body>
<div class="navbar-fixed-top">
    <div class="breadcrumb">
        <span>系统设置</span>/
        <span class="active">通话环境配置</span>
        <span class="pull-right" title="刷新">
           <div class="btn-refresh" onclick="location.replace(location.href);">
           	<img src="<%=basePath%>/images/refresh.png">
           </div>
        </span>
    </div>
</div>
<div class="container-fluid">
    <div class="container-fluid-main">
        <div class="page-header">
            <h3>通话环境配置</h3>
        </div>
        <div class="container-fluid" style="width: 80%;background: #FFF;">


            <form id="storge_site" class="form-horizontal bg-info" style="padding: 20px">
                <div class="form-group">
                    <label class="col-md-3 control-label">
                        <label class="text-danger" style="margin-right: 5px"></label>存储位置</label>
                    <div class="col-md-6">
                        <button class="btn btn-primary btn-sm edit" id="storge_edit">修改</button>
                        <button class="btn btn-primary btn-sm hide commit" id="storge_send">确定</button>
                        <button class="btn btn-primary btn-sm hide cancel" id="storge_cancel">取消</button>
                    </div>
                </div>
                <div class="form-group">
                    <label for="storge_upload" class="col-md-3 control-label">
                        <label class="text-danger" style="margin-right: 5px"></label>文件上传配置</label>
                    <div class="col-md-6">
                        <input disabled type="text" class="form-control input-sm" id="storge_upload"
                               name="uploadFileSavePath"
                               value="${envCallConfig.uploadFileSavePath}">
                        <span class="help-block"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label for="storge_temp_download" class="col-md-3 control-label">
                        <label class="text-danger" style="margin-right: 5px"></label>文件下载临时配置</label>
                    <div class="col-md-6">
                        <input disabled type="text" class="form-control input-sm" id="storge_temp_download"
                               name="downloadFileTempPath" value="${envCallConfig.downloadFileTempPath}">
                        <span class="help-block"></span>
                    </div>
                </div>
            </form>

            <form id="robot_config" class="form-horizontal bg-info" style="padding: 20px">
                <div class="form-group">
                    <label class="col-md-3 control-label">
                        <label class="text-danger" style="margin-right: 5px"></label>机器人配置</label>
                    <div class="col-md-6">
                        <button class="btn btn-primary btn-sm edit" id="robot_edit">修改</button>
                        <button class="btn btn-primary btn-sm hide commit" id="robot_send">确定</button>
                        <button class="btn btn-primary btn-sm hide cancel" id="robot_cancel">取消</button>
                    </div>
                </div>
                <div class="form-group">
                    <label for="max_robot_count" class="col-md-3 control-label">
                        <label class="text-danger" style="margin-right: 5px"></label>机器人最大数量(个)</label>
                    <div class="col-md-6">
                        <input disabled type="text" class="form-control input-sm" id="max_robot_count"
                               name="max_robot_count"
                               onkeyup="value=value.replace(/[^\d]/g,'')" value="${envCallConfig.maxRobotCount}">
                        <span class="help-block"></span>
                    </div>
                </div>

                <div class="form-group">
                    <label for="robot_status_refresh_freq" class="col-md-3 control-label">
                        <label class="text-danger" style="margin-right: 5px"></label>机器人状态刷新频率(秒)</label>
                    <div class="col-md-6">
                        <input disabled type="text" class="form-control input-sm" id="robot_status_refresh_freq"
                               name="robot_status_refresh_freq"
                               onkeyup="value=value.replace(/[^\d]/g,'')"
                               value="${envCallConfig.robotStatusRefreshFreq}">
                        <span class="help-block"></span>
                    </div>
                </div>

                <div class="form-group">
                    <label for="actual_get_robots_allocation_switch" class="col-md-3 control-label">
                        <label class="text-danger" style="margin-right: 5px"></label>是否按实际获取机器人数量分配</label>
                    <div class="col-md-6">
                        <select disabled class="form-control input-sm" id="actual_get_robots_allocation_switch"
                                name="actual_get_robots_allocation_switch">
                            <c:choose>
                                <c:when test="${envCallConfig.actualGetRobotsAllocationSwitch}">
                                    <option value="1" selected>启用</option>
                                    <option value="0">停用</option>
                                </c:when>
                                <c:otherwise>
                                    <option value="1">启用</option>
                                    <option value="0" selected>停用</option>
                                </c:otherwise>
                            </c:choose>
                        </select>
                        <span class="help-block"></span>
                    </div>
                </div>
            </form>
            <form id="real_time_config" class="form-horizontal bg-info" style="padding: 20px">

                <div class="form-group">
                    <label class="col-md-3 control-label">
                        <label class="text-danger" style="margin-right: 5px"></label>实时监听配置</label>
                    <div class="col-md-6">
                        <button class="btn btn-primary btn-sm edit" id="real_time_edit">修改</button>
                        <button class="btn btn-primary btn-sm hide commit" id="real_time_send">确定</button>
                        <button class="btn btn-primary btn-sm hide cancel" id="real_time_cancel">取消</button>
                    </div>
                </div>
                <div class="form-group">
                    <label for="real_time_switch" class="col-md-3 control-label">
                        <label class="text-danger" style="margin-right: 5px"></label>是否启用实时监听</label>
                    <div class="col-md-6">
                        <select disabled class="form-control input-sm" id="real_time_switch" name="real_time_switch">
                            <c:choose>
                                <c:when test="${envCallConfig.realTimeSwitch}">
                                    <option value="1" selected>启用</option>
                                    <option value="0">停用</option>
                                </c:when>
                                <c:otherwise>
                                    <option value="1">启用</option>
                                    <option value="0" selected>停用</option>
                                </c:otherwise>
                            </c:choose>
                        </select>
                        <span class="help-block"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label for="real_time_interval" class="col-md-3 control-label">
                        <label class="text-danger" style="margin-right: 5px"></label>实时监听间隔(毫秒)</label>
                    <div class="col-md-6">
                        <input disabled type="text" class="form-control input-sm" id="real_time_interval"
                               name="real_time_interval" value="${envCallConfig.realTimeInitInterval}">
                        <span class="help-block"></span>
                    </div>
                </div>
            </form>
            <form id="interface_config" class="form-horizontal bg-info" style="padding: 20px">
                <div class="form-group">
                    <label class="col-md-3 control-label">
                        <label class="text-danger" style="margin-right: 5px"></label>接口配置</label>
                    <div class="col-md-6">
                        <button class="btn btn-primary btn-sm edit" id="interface_edit">修改</button>
                        <button class="btn btn-primary btn-sm hide commit" id="interface_send">确定</button>
                        <button class="btn btn-primary btn-sm hide cancel" id="interface_cancel">取消</button>
                    </div>
                </div>
                <div class="form-group">
                    <label for="call_finish_listener_interval" class="col-md-3 control-label">
                        <label class="text-danger" style="margin-right: 5px"></label>通话完成监听间隔(秒)</label>
                    <div class="col-md-6">
                        <input disabled type="text" class="form-control input-sm" id="call_finish_listener_interval"
                               name="call_finish_listener_interval"
                               onkeyup="value=value.replace(/[^\d]/g,'')"
                               value="${envCallConfig.callFinishListenerInterval}">
                        <span class="help-block"></span>
                    </div>
                </div>

                <div class="form-group">
                    <label for="add_task_url" class="col-md-3 control-label">
                        <label class="text-danger" style="margin-right: 5px"></label>添加任务地址</label>
                    <div class="col-md-6">
                        <input disabled type="text" class="form-control input-sm" id="add_task_url"
                               name="add_task_url" value="${envCallConfig.addTaskUrl}">
                        <span class="help-block"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label for="query_tasks_url" class="col-md-3 control-label">
                        <label class="text-danger" style="margin-right: 5px"></label>查询通话信息地址</label>
                    <div class="col-md-6">
                        <input disabled type="text" class="form-control input-sm" id="query_tasks_url"
                               name="query_tasks_url" value="${envCallConfig.queryTasksUrl}">
                        <span class="help-block"></span>
                    </div>
                </div>

                <div class="form-group">
                    <label for="get_call_result_url" class="col-md-3 control-label">
                        <label class="text-danger" style="margin-right: 5px"></label>获取通话结果地址</label>
                    <div class="col-md-6">
                        <input disabled type="text" class="form-control input-sm" id="get_call_result_url"
                               name="get_call_result_url" value="${envCallConfig.getCallResultUrl}">
                        <span class="help-block"></span>
                    </div>
                </div>

                <div class="form-group">
                    <label for="del_call_result_url" class="col-md-3 control-label">
                        <label class="text-danger" style="margin-right: 5px"></label>删除通话结果地址</label>
                    <div class="col-md-6">
                        <input disabled type="text" class="form-control input-sm" id="del_call_result_url"
                               name="del_call_result_url" value="${envCallConfig.delCallResultUrl}">
                        <span class="help-block"></span>
                    </div>
                </div>

                <div class="form-group">
                    <label for="get_business_script_url" class="col-md-3 control-label">
                        <label class="text-danger" style="margin-right: 5px"></label>获取业务脚本地址</label>
                    <div class="col-md-6">
                        <input disabled type="text" class="form-control input-sm" id="get_business_script_url"
                               name="get_business_script_url" value="${envCallConfig.getBusinessScriptUrl}">
                        <span class="help-block"></span>
                    </div>
                </div>

                <div class="form-group">
                    <label for="robot_query_status_url" class="col-md-3 control-label">
                        <label class="text-danger" style="margin-right: 5px"></label>机器人状态查询地址</label>
                    <div class="col-md-6">
                        <input disabled type="text" class="form-control input-sm" id="robot_query_status_url"
                               name="robot_query_status_url" value="${envCallConfig.robotQueryStatusUrl}">
                        <span class="help-block"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label for="grpc_server_url" class="col-md-3 control-label">
                        <label class="text-danger" style="margin-right: 5px"></label>连接GRPC地址</label>
                    <div class="col-md-6">
                        <input disabled type="text" class="form-control input-sm" id="grpc_server_url"
                               name="grpc_server_url" value="${envCallConfig.grpcServerUrl}">
                        <span class="help-block"></span>
                    </div>
                </div>
            </form>

<%--            <form id="pre_tts_config" class="form-horizontal bg-info" style="padding: 20px" hidden>--%>
<%--                <div class="form-group">--%>
<%--                    <label class="col-md-3 control-label">--%>
<%--                        <label class="text-danger" style="margin-right: 5px"></label>预合成配置</label>--%>
<%--                    <div class="col-md-6">--%>
<%--                        <button class="btn btn-primary btn-sm edit" id="pre_tts_edit">修改</button>--%>
<%--                        <button class="btn btn-primary btn-sm hide commit" id="pre_tts_send">确定</button>--%>
<%--                        <button class="btn btn-primary btn-sm hide cancel" id="pre_tts_cancel">取消</button>--%>
<%--                    </div>--%>
<%--                </div>--%>
<%--                <div class="form-group">--%>
<%--                    <label for="pre_tts_url" class="col-md-3 control-label">--%>
<%--                        <label class="text-danger" style="margin-right: 5px"></label>预合成地址</label>--%>
<%--                    <div class="col-md-6">--%>
<%--                        <input disabled type="text" class="form-control input-sm" id="pre_tts_url" name="pre_tts_url"--%>
<%--                               value="${envPreTTSConfig.preTtsUrl}">--%>
<%--                        <span class="help-block"></span>--%>
<%--                    </div>--%>
<%--                </div>--%>

<%--                <div class="form-group">--%>
<%--                    <label for="pre_tts_count_times" class="col-md-3 control-label">--%>
<%--                        <label class="text-danger" style="margin-right: 5px"></label>预合成缓存倍数</label>--%>
<%--                    <div class="col-md-6">--%>
<%--                        <input disabled type="text" class="form-control input-sm" id="pre_tts_count_times"--%>
<%--                               name="pre_tts_count_times"--%>
<%--                               onkeyup="value=value.replace(/[^\d]/g,'')"--%>
<%--                               value="${envPreTTSConfig.preTtsCountTimes}">--%>
<%--                        <span class="help-block"></span>--%>
<%--                    </div>--%>
<%--                </div>--%>

<%--                <div class="form-group">--%>
<%--                    <label for="pre_tts_retry_times" class="col-md-3 control-label">--%>
<%--                        <label class="text-danger" style="margin-right: 5px"></label>预合成重试次数</label>--%>
<%--                    <div class="col-md-6">--%>
<%--                        <input disabled type="text" class="form-control input-sm" id="pre_tts_retry_times"--%>
<%--                               name="pre_tts_retry_times"--%>
<%--                               onkeyup="value=value.replace(/[^\d]/g,'')"--%>
<%--                               value="${envPreTTSConfig.preTtsRetryTimes}">--%>
<%--                        <span class="help-block"></span>--%>
<%--                    </div>--%>
<%--                </div>--%>

<%--                <div class="form-group">--%>
<%--                    <label for="pre_tts_retry_interval" class="col-md-3 control-label">--%>
<%--                        <label class="text-danger" style="margin-right: 5px"></label>预合成重试间隔(秒)</label>--%>
<%--                    <div class="col-md-6">--%>
<%--                        <input disabled type="text" class="form-control input-sm" id="pre_tts_retry_interval"--%>
<%--                               name="pre_tts_retry_interval"--%>
<%--                               onkeyup="value=value.replace(/[^\d]/g,'')"--%>
<%--                               value="${envPreTTSConfig.preTtsRetryInterval}">--%>
<%--                        <span class="help-block"></span>--%>
<%--                    </div>--%>
<%--                </div>--%>
<%--                <div class="form-group">--%>
<%--                    <label for="pre_tts_request_timeout" class="col-md-3 control-label">--%>
<%--                        <label class="text-danger" style="margin-right: 5px"></label>预合成请求超时(秒)</label>--%>
<%--                    <div class="col-md-6">--%>
<%--                        <input disabled type="text" class="form-control input-sm" id="pre_tts_request_timeout"--%>
<%--                               name="pre_tts_request_timeout"--%>
<%--                               onkeyup="value=value.replace(/[^\d]/g,'')"--%>
<%--                               value="${envPreTTSConfig.preTtsRequestTimeout}">--%>
<%--                        <span class="help-block"></span>--%>
<%--                    </div>--%>
<%--                </div>--%>
<%--            </form>--%>

            <form id="recorder_config" class="form-horizontal bg-info" style="padding: 20px">

                <div class="form-group">
                    <label class="col-md-3 control-label">
                        <label class="text-danger" style="margin-right: 5px"></label>系统录音配置</label>
                    <div class="col-md-6">
                        <button class="btn btn-primary btn-sm edit" id="recorder_edit">修改</button>
                        <button class="btn btn-primary btn-sm hide commit" id="recorder_send">确定</button>
                        <button class="btn btn-primary btn-sm hide cancel" id="recorder_cancel">取消</button>
                    </div>
                </div>

                <div class="form-group">
                    <label for="typeCode" class="col-md-3 control-label">
                        <label class="text-danger" style="margin-right: 5px"></label>录音存储模式</label>
                    <div class="col-md-6">
                        <select disabled class="form-control input-sm" id="typeCode" name="typeCode">

                            <c:forEach items="${resLoadInfoList}" var="item">
                                <option value="${item.typeCode}"
                                        <c:choose>
                                            <c:when test="${envCallConfig.resLoadInfo.typeCode == item.typeCode}">
                                                selected
                                            </c:when>
                                        </c:choose>
                                > ${item.typeName}</option>
                            </c:forEach>

                        </select>
                        <span class="help-block"></span>
                    </div>
                </div>

                <div class="form-group">
                    <label for="typeContent" class="col-md-3 control-label">
                        <label class="text-danger" style="margin-right: 5px"></label>录音存储地址</label>
                    <div class="col-md-6">
                        <input disabled type="text" class="form-control input-sm" id="typeContent"
                               name="typeContent" value="${envCallConfig.resLoadInfo.typeContent}"
                               onkeyup="value=value.replace(/[^a-zA-Z0-9\u4E00-\u9FA5\_\/\\]/g,'')">
                        <span class="help-block"></span>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<script type="text/javascript" src="<%=basePath%>/lib/jquery/1.11.0/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="<%=basePath%>/lib/bootstrap/3.3.7/js/bootstrap.js"></script>
<script type="text/javascript" src="<%=basePath%>/lib/jquery.validation/1.14.0/jquery.validate_1.js"></script>
<script type="text/javascript" src="<%=basePath%>/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="<%=basePath%>/lib/lobibox/js/lobibox.min.js"></script>
<script type="text/javascript" src="<%=basePath%>/lib/lobibox/js/messageboxes.min.js"></script>
<script type="text/javascript" src="<%=basePath%>/lib/lobibox/js/notifications.min.js"></script>
<script type="text/javascript" src="<%=basePath%>/lib/JQuery.md5.js"></script>
<script type="text/javascript" src="<%=basePath%>/js/common.js"></script>


<script type="text/javascript">
    var outcryarr = null, storgearr = null, robotarr = null, recorderarr = null, prettsarr = null, infarr = null,
        realTimeArr = null, incomingCallArr = [];
    //定义提交的地址
    var outcryaddress = '<%=basePath%>/config/updateCallEnvConfig.do',
        storgeaddress = '<%=basePath%>/config/updateStoreCallEnvConfig.do',
        robotaddress = '<%=basePath%>/config/updateRobotCallEnvConfig.do',
        <%--pre_tts_update_url = '<%=basePath%>/config/updatePreTtsConfig.do',--%>
        recorderaddress = '<%=basePath%>/config/updateResLoadInfoConfig.do',
        interface_url = '<%=basePath%>/config/updateInterfaceCallEnvConfig.do',
        real_time_update_url = '<%=basePath%>/config/updateRealTimeConfig.do';
        <%--incoming_call_update_url = '<%=basePath%>/config/updateIncomingCallConfig.do';--%>
    $(function () {
        $("#typeCode").on("change", function (e) {
            var $val = $(this).val();
            $.ajax({
                url: "<%=basePath%>/config/getResLoadInfo.do",
                type: 'POST',
                data: {
                    "typeCode": $val
                },
                async: false,
                success: function (data) {
                    //设置获取过来的文本
                    $("#typeContent").val(data["object"].typeContent);
                },
                error: function () {
                    myNotify("error", "", "请求数据发生错误，请联系管理员！");
                }
            });
        });
        //设置后台取到的值为int类型
        var storgeValidate = $("#storge_site").validate({
            errorPlacement: function (error, element) {
                $(element)
                    .closest("div.form-group")
                    .find("span.help-block")
                    .append(error);
            },
            errorElement: "p",
            rules: {
                uploadFileSavePath: {
                    required: true,
                    isLinuxRouter: true
                },
                downloadFileTempPath: {
                    required: true,
                    isLinuxRouter: true
                }
            },
            messages: {}
        });


        var robotValidate = $("#robot_config").validate({
            errorPlacement: function (error, element) {
                // Append error within linked label
                //console.log(element)
                $(element)
                    .closest("div.form-group")
                    .find("span.help-block")
                    .append(error);
            },
            errorElement: "p",
            rules: {
                max_robot_count: {
                    required: true,
                    isGtNum: 0,
                    isInteger: true
                },
                robot_status_refresh_freq: {
                    required: true,
                    isGtNum: 0,
                    isInteger: true
                }
            },
            messages: {}
        });
        var interfaceValidate = $("#interface_config").validate({
            errorPlacement: function (error, element) {
                // Append error within linked label
                //console.log(element)
                $(element)
                    .closest("div.form-group")
                    .find("span.help-block")
                    .append(error);
            },
            errorElement: "p",
            rules: {
                call_finish_listener_interval: {
                    required: true,
                    isGtNum: 0,
                    isInteger: true
                },
                add_task_url: {
                    required: true,
                    isHttp: true
                },
                query_tasks_url: {
                    required: true,
                    isHttp: true
                },
                get_call_result_url: {
                    required: true,
                    isHttp: false
                },
                del_call_result_url: {
                    required: true,
                    isHttp: false
                },
                get_business_script_url: {
                    required: true,
                    isHttp: false
                },
                robot_query_status_url: {
                    required: true,
                    isHttp: false
                },
                grpc_server_url: {
                    required: true,
                    isHttp: false
                }
            },
            messages: {}
        });
        // var preTtsValidate = $("#pre_tts_config").validate({
        //     errorPlacement: function (error, element) {
        //         // Append error within linked label
        //         //console.log(element)
        //         $(element)
        //             .closest("div.form-group")
        //             .find("span.help-block")
        //             .append(error);
        //     },
        //     errorElement: "p",
        //     rules: {
        //         pre_tts_count_times: {
        //             required: true,
        //             isGtNum: 0,
        //             isInteger: true
        //         },
        //         pre_tts_retry_times: {
        //             required: true,
        //             isGtNum: 0,
        //             isInteger: true
        //         },
        //         pre_tts_retry_interval: {
        //             required: true,
        //             isGtNum: 0,
        //             isInteger: true
        //         },
        //         pre_tts_request_timeout: {
        //             required: true,
        //             isGtNum: 0,
        //             isInteger: true
        //         },
        //         pre_tts_url: {
        //             required: true,
        //             isHttp: true
        //         }
        //
        //     },
        //     messages: {}
        // });

        var recorderValidate = $("#recorder_config").validate({
            errorPlacement: function (error, element) {
                $(element)
                    .closest("div.form-group")
                    .find("span.help-block")
                    .append(error);
            },
            errorElement: "p",
            rules: {
                typeContent: {
                    required: true
                }
            },
            messages: {}
        });

        var realTimeValidate = $("#real_time_config").validate({
            errorPlacement: function (error, element) {
                $(element)
                    .closest("div.form-group")
                    .find("span.help-block")
                    .append(error);
            },
            errorElement: "p",
            rules: {
                real_time_interval: {
                    required: true,
                    isGtNum: 0,
                    isInteger: true
                }
            },
            messages: {}
        });

        $(".edit").on("click", function () {
            var from = $(this).closest("form");
            from.find(":disabled").attr("disabled", false);
            getFromvalue(from)
            $(this).addClass("hide").nextAll().removeClass("hide");
            return false;
        })

        $(".cancel").on("click", function () {
            var my_form = $(this).closest("form");
            if (my_form.is($("#storge_site"))) {
                setFromvalue(my_form, storgearr);
                storgeValidate.resetForm();
            } else if (my_form.is($("#recorder_config"))) {
                setFromvalue(my_form, recorderarr);
                recorderValidate.resetForm();
            } else if (my_form.is($("#robot_config"))) {
                setFromvalue(my_form, robotarr);
                robotValidate.resetForm();
            } else if (my_form.is($("#real_time_config"))) {
                setFromvalue(my_form, realTimeArr);
                realTimeValidate.resetForm();
            } else {
                setFromvalue(my_form, infarr);
                interfaceValidate.resetForm();
            }
            my_form.find(".form-control").attr("disabled", true);
            $(this).addClass("hide").siblings(".commit").addClass("hide").siblings(".edit").removeClass("hide");
            return false;
        })

        $(".commit").on("click", function () {
            var from = $(this).closest("form");
            var url = "";
            if (from.is($("#storge_site"))) {
                url = storgeaddress;
            } else if (from.is($("#recorder_config"))) {
                url = recorderaddress;
            } else if (from.is($("#robot_config"))) {
                url = robotaddress;
            } else if (from.is($("#real_time_config"))) {
                url = real_time_update_url;
            } else {
                url = interface_url;
            }
            var $this=this;
            if (from.valid()) {
                $.ajax({
                    url: url,
                    type: 'POST',
                    data: from.serialize(),
                    async: false,
                    success: function (data) {
                        if (data['errorCode'] == 0) {
                            myNotify("success", "", "修改成功");
                        } else {
                            myNotify("error", "", "修改失败");
                        }
                        getFromvalue(from)
                        from.find(".form-control").attr("disabled", true);
                        $($this).addClass("hide").siblings(".cancel").addClass("hide").siblings(".edit").removeClass("hide");
                    },
                    error: function () {
                        myNotify("error", "", "提交表单过程中过程中发生错误，请联系管理员！");
                    }
                });

            } else {
                myNotify("error", "", "请先修复错误后在进行提交");
            }
            return false
        })
    });

    /******************************方法声明**********************************/
    function setFromvalue($from, data) {
        $.each(data, function (i, item) {
            $from.find("[name='" + item.name + "']").val(item.value)
        })
    }

    function getFromvalue(mfrom) {
        var fromarr = mfrom.serializeArray();
        if (mfrom.is($("#storge_edit"))) {
            storgearr = fromarr;
        } else if (mfrom.is($("#recorder_config"))) {
            recorderarr = fromarr;
        } else if (mfrom.is($("#robot_config"))) {
            robotarr = fromarr;
        } else if (mfrom.is($("#real_time_config"))) {
            realTimeArr = fromarr;
        } else {
            infarr = fromarr;
        }
    }
</script>

</body>
</html>